package com.air.config;

import com.air.exception.ParamsErrorException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@ControllerAdvice
public class ExceptionControllerAdvice {

    @ResponseBody
    @ExceptionHandler(value = {ParamsErrorException.class})
    public Result<Object> resolveParamsErrorException(ParamsErrorException e,
                                                      HttpServletRequest request,
                                                      HttpServletResponse response) throws IOException {

        return Result.fail(e.getMessage());
    }

}
